window.View = function()
{
    // 获取接口路径
    this.Paths = null;
    // 获取所有选中元素
    this.Elems = null;
    // 视图模板
    this.Tmps = null;

    this.chartBtn = null;

    this.analysisType = -1;

    this.analysisCode = -1;
};

View.prototype = {

    /** 初始化视图*/
    init : function( o )
    {
        this.lib = o.lib || null ;
        // 获取接口路径
        this.Paths = o.paths;
        // 获取所有选中元素
        this.Elems = this.H.getElementsByIds( o.ids );
        // 获取所有视图模板
        this.Tmps = this.H.getTemplatesModle( o.templates );

        this.Elems["loading"] = top.window.FRAMES["container"].window.document.getElementById("ad-js-loading") || this.Elems["loading"];

        this.analysisType = this.Elems["analysisType"].value || -1;

        this.analysisCode = this.Elems["analysisCode"].value || -1;

        this.bindEvent();

        // 初始化select2
        var self = this;

        var oCascadeData = new self.CascadeData();

        oCascadeData.init( this.Paths["getrelationPath"]);

        $("select.ad-js-select").select2({
            //placeholder: "请选择查询条件",
            allowClear: true
        }).on("change", function( e )
        {
            self.beforeSend();

            var result = self.Control.select2ChangeHandle( e, self.Elems["allsearchform"].children, self );

            oCascadeData.askdata( result, function( data )
            {
                for( var attr in data )
                {
                    var oselect = document.getElementById( "select_" + attr.toUpperCase() );

                    var tv = self.$( oselect ).select2("val");

                    if( !oselect ) continue;

                    var ofrag = document.createDocumentFragment();

                    for( var i = 0, item; item = data[ attr ][ i ]; i += 1 )
                    {
                        var newOption = document.createElement("option");

                        newOption.value = item.id;

                        newOption.innerHTML = item.name;

                        ofrag.appendChild( newOption );
                    }

                    oselect.innerHTML = "";

                    oselect.appendChild( ofrag );

                    self.$( oselect).select2("val",tv);
                }

                self.afterSend();
            });
        });

        $('input.ad-js-timer').glDatePicker({
            showAlways : false,
            format : 'yyyy-mm-dd',
            nextArrow : ">",
            prevArrow : "<",
            dowNames : [ "日", "一", "二", "三", "四", "五", "六" ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ]
        });

        //this.Elems["search"].onclick();

        this.charts = this.echarts.init( this.Elems["chartsContainer"] );

        var oRel = new this.Relational();

        oRel.init( this.Elems["RelationalPath"].value || null, this.Control.getCondItem, this.Control.getItem, this.Control );
    },

    saveAxisHandle : function()
    {
        this.Control.saveAxis(
            this.Elems["xAxisCond"].getElementsByTagName("a"),
            this.Elems["yAxisCond"].getElementsByTagName("a")
        );

        this.getViewItem( this.Control.getCondItem() );
    },

    _sideBarEvent : function()
    {
        var self = this;

        self.Elems["submitSide"].onclick = function()
        {
            var sendData = self.Control.getCondItem();

            if( !( sendData["xAxis"] && sendData["yAxis"] ) )
            {
                self.toastr.warning("你还未选择<维度>");

                self.$( "a:eq( 0 )", self.Elems["tabs2"] ).tab("show");

                return false;
            }

            if( !sendData["vAxis"] )
            {
                self.toastr.warning("你还未选择<统计方式>");

                self.$( "a:eq( 1 )", self.Elems["tabs2"] ).tab("show");

                return false;
            }

            self.Control.setSubmitConditionItem( sendData );

            self.getTableItem( sendData )
        }

        self.Elems["condcontainer"].onmouseover = function()
        {
            self.Elems["sliderbar"].style.right = -self.Elems["sliderbar"].offsetWidth + "px";

            return false;
        }

        self.Elems["condcontainer"].onmouseout = function()
        {
            if( !parseInt( self.Elems["tableAxisContainer"].style.left , 10 ) )
            {
                self.Elems["sliderbar"].style.right = 0;
            }

            return false;
        }

        self.Elems["sliderbar"].onclick = function()
        {
            self.Elems["condcontainer"].style.left = 0;

            self.Elems["sliderbar"].style.right = -self.Elems["sliderbar"].offsetWidth + "px";

            self.Elems["tableViewContainer"].style.zIndex = 0;

            self.Elems["tableViewContainer"].style.opacity = 1;

            self.Elems["tableViewContainer"].style.left = self.Elems["condcontainer"].offsetWidth + "px";

            this.style.opacity = 0;

            self.$( "button:not(:eq(1))", self.Elems["obtns"] ).addClass("disabled");

            self.Elems["closeallsearchwrap"].onclick();

        }


        self.Elems["configMode"].onclick = function()
        {
            self.Elems["sliderbar"].onclick();
        }

        self.Elems["closeSide"].onclick = function()
        {
            self.Elems["condcontainer"].style.left = -( self.Elems["condcontainer"].offsetWidth - 3 ) + "px";

            self.Elems["tableViewContainer"].style.left = 0;

            self.Elems["tableViewContainer"].style.opacity = 0;

            self.Elems["tableViewContainer"].style.zIndex = self.Elems["tableAxisContainer"].style.zIndex = -1;

            self.Elems["sliderbar"].style.right = 0;

            self.Elems["sliderbar"].style.opacity = 1;

            self.$( "button:not(:eq(1))", self.Elems["obtns"] ).removeClass("disabled");
        }

        self.Elems["editSide"].onclick = function()
        {
            var $wrap = self.$( self.Elems["tableAxisContainer"] );

            if( $wrap.css("z-index") <= 0 )
            {
                $wrap.css( "z-index", 1 );
                var index = self.$( "li.active", self.Elems["tabs2"]).index();

                if( index )
                {
                    self.Elems["xAxisCond"].parentNode.style.display = "none";
                    self.Elems["yAxisCond"].parentNode.style.display = "none";
                    self.Elems["valueAxis"].parentNode.style.display = "block";
                }
                else
                {
                    self.Elems["xAxisCond"].parentNode.style.display = "block";
                    self.Elems["yAxisCond"].parentNode.style.display = "block";
                    self.Elems["valueAxis"].parentNode.style.display = "none";
                }

            }
            else
            {
                $wrap.css( "z-index", -2 );

                self.Elems["xAxisCond"].parentNode.style.display = "none";
                self.Elems["yAxisCond"].parentNode.style.display = "none";
                self.Elems["valueAxis"].parentNode.style.display = "none";

            }
        }

        self.Elems["resetSide"].onclick = function()
        {
            self.$( [ self.Elems["xAxisCond"], self.Elems["yAxisCond"], self.Elems["valueAxis"] ] ).html("无");

            self.$( "a", self.Elems["dataAxis"]).removeClass("disabled");

            self.$( "input:checkbox", self.Elems["dataValue"]).each( function()
            {
                this.checked = false;
            });

            self.Elems["closeEditMode"].onclick();

            self.Control.resetAxis();

            self.Control.resetValueAxis();

            self.Control.resetTmpValueAxis();

            self.getViewItem( self.Control.getCondItem() );
        }

        self.Elems["closeEditMode"].onclick = function()
        {
            self.Elems["tableAxisContainer"].style.zIndex = -1;

            self.Elems["xAxisCond"].parentNode.style.display = "none";
            self.Elems["yAxisCond"].parentNode.style.display = "none";
            self.Elems["valueAxis"].parentNode.style.display = "none";
        }
    },

    _condEvent : function()
    {
        var self = this;

        self.$( "a", self.Elems["dataAxis"] ).mousedown( function( e )
        {
            self.Elems["tableAxisContainer"].style.zIndex = 1;

            self.Elems["xAxisCond"].parentNode.style.display = "block";
            self.Elems["yAxisCond"].parentNode.style.display = "block";
            self.Elems["valueAxis"].parentNode.style.display = "none";

            var _this = this;
            var $prev = null;
            var hoverName = "hover";
            self.$( document.getElementById("dragElem") ).remove();
            var clone = _this.cloneNode( true );
            clone.id = "dragElem";
            clone.style.position = "absolute";
            clone.style.zIndex = 10000;
            clone.style.top = ( e.clientY ) + "px";
            clone.style.left = ( e.clientX + 5 ) +  "px";
            clone.style.opacity = .8;
            document.body.appendChild( clone );

            window.onmousemove = function( e )
            {
                clone.style.top = ( e.clientY ) + "px";
                clone.style.left = ( e.clientX + 5 )  + "px";

                var $target = self.$( e.target );
                var className = "ad-js-target";

                var $prent = $target.parents("div." + className );

                $prev && $prev.removeClass( hoverName );

                if( $prent[ 0 ] )
                {
                    $prent.addClass( hoverName );

                    $prev = $prent;
                }
                else if( $target.hasClass( className ) )
                {
                    $target.addClass( hoverName );

                    $prev = $target;
                }
                else
                {
                    $prev = null;
                }
            }

            window.onmouseup = function()
            {
                $prev && $prev.removeClass( hoverName );

                if( $prev )
                {
                    var wrap = $prev.children("div");

                    if( _this.getAttribute("data-step") )
                    {
                        self.Elems["submitStep"]._sendOpt = {
                            wrap : wrap,
                            node : clone,
                            current : _this
                        };

                        self.$( self.Elems["setStep"] ).modal('show');

                        self.$( "li:eq(0) a", self.Elems["stepTab"] ).attr( "data-step", _this.getAttribute("data-step") || null ).tab('show');

                        self.Elems["submitStep"]._idx = 0;

                        var inputs = self.Elems["tabContent2"].getElementsByTagName("form")[ 0 ].getElementsByTagName("input");

                        var dataStep =  _this.getAttribute("data-step");

                        var aStep = dataStep.split(",");

                        inputs[ 0 ].value = aStep[ 0 ];

                        self.$( "span.ad-js-setuom", self.Elems["tabContent2"] ).html( aStep[ 4 ] || "未知" );

                        inputs[ 1 ].value = aStep[ 1 ];

                        inputs[ 2 ].value = aStep[ 2 ];

                        self.Elems["addStep"].style.display = "none";

                        self.Elems["submitStep"]._range = parseInt( aStep[ 3 ] ) || 0;

                        self.Elems["submitStep"]._uom = aStep[ 4 ] || "未知";

                        self.Elems["submitStep"]._uomNum = aStep[ 5 ] || null;

                        self.Elems["submitStep"]._sendOpt._step = aStep ;
//
                        self.Elems["submitStep"]._sendOpt.dataStep = aStep;
                    }
                    else
                    {
                        var node = clone;

                        var data = [{ title : node.innerHTML || "未知", value : node.getAttribute("data-name") || "null" }];

                        var element = self.Control.printDataToMapPanel( data, self.Tmps["xyAxis"] );

                        if( !wrap.children().length ) wrap.html("");

                        wrap.append( element );

                        self.$( _this ).addClass("disabled");

                        self.Elems["tableAxisContainer"].style.zIndex = 0;

                        // 保存横向纵向纬度
                        self.saveAxisHandle();
                    }
                }
                else
                {
                    self.Elems["tableAxisContainer"].style.zIndex = 0;
                }

                self.$( clone ).remove();

                window.onmouseup = window.onmousemove = null;
            };

        });

        self.$( self.Elems["setStep"] ).on( 'show.bs.modal', function ()
        {
            //alert( "显示" )
        });

        self.$( self.Elems["setStep"] ).on( 'hide.bs.modal', function ()
        {
            self.Elems["tableAxisContainer"].style.zIndex = 0;
        });


        self.$( "li:eq(0) a", self.Elems["tabs2"] ).on( 'show.bs.tab', function ()
        {
            self.Elems["xAxisCond"].parentNode.style.display = "block";
            self.Elems["yAxisCond"].parentNode.style.display = "block";
            self.Elems["valueAxis"].parentNode.style.display = "none";
        });

        self.$( "li:eq(1) a", self.Elems["tabs2"] ).on( 'show.bs.tab', function ()
        {
            self.Elems["xAxisCond"].parentNode.style.display = "none";
            self.Elems["yAxisCond"].parentNode.style.display = "none";
            self.Elems["valueAxis"].parentNode.style.display = "block";
        });

        self.$( "li:eq(0) a", self.Elems["stepTab"] ).on('show.bs.tab', function( e )
        {
            var inputs = self.Elems["tabContent2"].getElementsByTagName("form")[ 0 ].getElementsByTagName("input");

            var aStep = e.target.getAttribute("data-step").split(",");

            inputs[ 0 ].value = aStep[ 0 ];

            inputs[ 1 ].value = aStep[ 1 ];

            inputs[ 2 ].value = aStep[ 2 ];

            self.Elems["addStep"].style.display = "none";

            self.Elems["submitStep"]._idx = 0;
        })

        self.$( "li:eq(1) a", self.Elems["stepTab"] ).on('show.bs.tab', function()
        {
            var tabGroup = self.Elems["tabContent2"].getElementsByTagName("form")[ 1 ].children;

            if( tabGroup.length > 1 )
            {
                self.$( tabGroup ).eq( 0 ).siblings().remove();
            }
            else
            {
                var inputs = tabGroup[ 0 ].getElementsByTagName("input");

                inputs[ 0 ].value = 0;

                inputs[ 1 ].value = "";
            }

            self.Elems["addStep"].style.display = "inline-block";

            self.Elems["submitStep"]._idx = 1;
        })

        self.Elems["addStep"].onclick = function()
        {
            var inputGroup = self.Elems["tabContent2"].getElementsByTagName("form")[ 1 ].children[ 0 ].cloneNode( true );

            var closeBtn = document.createElement("button");

            closeBtn.type = "button";

            closeBtn.className = "btn btn-danger btn-sm";

            closeBtn.innerHTML = "<i class='fa fa-times'></i>";

            closeBtn._parent = inputGroup;

            var closeBtnWrap = document.createElement("span");

            closeBtnWrap.style.marginLeft = 10 + "px";

            closeBtnWrap.className = "input-group-btn";

            closeBtnWrap.appendChild( closeBtn );

            inputGroup.children[ 0 ].children[ 0 ].appendChild( closeBtnWrap );

            var input = inputGroup.getElementsByTagName("input");

            input[ 0 ].value = input[ 1 ].value = "";

            self.Elems["tabContent2"].getElementsByTagName("form")[ 1 ].appendChild( inputGroup );

            closeBtn.onclick = function()
            {
                this._parent.parentNode.removeChild( this._parent );
            }
        }

        self.Elems["submitStep"].onclick = function()
        {
            var sStep = "";

            this._sendOpt["_idx"] = this._idx;

            var option = {};

            if( this._idx == 0 )
            {
                var inputs = self.Elems["tabContent2"].getElementsByTagName("form")[ 0 ].getElementsByTagName("input");

                var res = [];

                for( var i = 0,f; f = inputs[ i ]; i += 1 )
                {
                    if( f.value != parseInt( f.value, 10 ) || f.value.indexOf(".") != -1 )
                    {
                        self.toastr.warning("请输入整数");

                        return false;
                    }

                    res.push( parseInt( f.value, 10 ) || 0 );
                }

                var start = res[ 0 ];
                var end = res[ 1 ];
                var step = res[ 2 ];

                if( start > end )
                {
                    self.toastr.warning("<最小值>不能大于<最大值>");

                    return false;
                }

                var arr = [];

                var iLen = ( end - start )%step === 0 ? end/step : end/step + 1;

                for( var i = 0; i < iLen; i += 1 )
                {
                    if( ( ( i + 1 )*step + start ) > end  )
                    {
                        arr.push( ( i*step + start ) + "-" + end )

                        break;
                    }

                    if( ( ( ( i + 1 )*step + start ) - ( i*step + start ) ) < this._range )
                    {
                        self.toastr.warning("区间不能小于" + ( this._range +  ( this._uom || "未知" ) ) + "" );

                        return false;
                    }

                    arr.push( ( i*step + start ) + "-" + ( ( i + 1 )*step + start ) )
                }

                option = {"start":start , "end" : end , "step" : step };

                sStep = arr.join("|");
            }
            else if( this._idx == 1 )
            {
                var inputGroup = self.Elems["tabContent2"].getElementsByTagName("form")[ 1 ].children;

                var res = [];

                var res1 = [];

                var prevalue = 0;


                for( var i = 0, gf; gf = inputGroup[ i ]; i += 1 )
                {
                    var inputs = gf.getElementsByTagName("input");

                    var value1 = inputs[ 0 ].value;

                    var value2 = inputs[ 1 ].value;

                    if( !( inputs[ 0 ].value.indexOf(".") && inputs[ 1 ].value.indexOf(".") ) )
                    {
                        self.toastr.warning("区间值必须为整数");
                    }

                    value1 = parseInt( inputs[ 0 ].value, 10 );

                    value2 = parseInt( inputs[ 1 ].value, 10 );

                    if( !( value1 > -1 && value2 > -1 ) )
                    {
                        self.toastr.warning("自定义区间输入有误");

                        return false;
                    }

                    if( value2 < value1 )
                    {
                        self.toastr.warning("自定义区间范围输入有误");

                        return false;
                    }

                    if( Math.abs( value2 - value1 ) <= this._range )
                    {
                        self.toastr.warning("区间不能小于" + ( this._range +  ( this._uom || "未知" ) ) + "" );

                        return false;
                    }

                    if( prevalue > value1 )
                    {
                        self.toastr.warning("区间组输入有误" );

                        return false;
                    }

                    if( value1 > value2 )
                    {
                        self.toastr.warning("区间组输入有误" );

                        return false;
                    }

                    res.push( value1 + "-" + value2 )

                    prevalue = value2;


                    res1.push( value1+","+value2 )

                }

                option = { "arr" : res1 };

                sStep = res.join("|");
            }

            var node = this._sendOpt.node;

            var data = [{ title : node.innerHTML || "未知", value : node.getAttribute("data-name") || "null" }];

            var element = self.Control.printDataToMapPanel( data, self.Tmps["xyAxis"] );

            if( !this._sendOpt.wrap.children().length ) this._sendOpt.wrap.html("");

            this._sendOpt.wrap.append( element );

            self.$( this._sendOpt.current ).addClass("disabled");

            self.$( self.Elems["setStep"]).modal("hide");

            var oA = element.find("a");

            oA.attr({ "data-step" : sStep, "data-uom" : this._uomNum } );

            oA._sendOpt = this._sendOpt;

            oA._sendOpt.value = option;

            oA[0]._sendOpt = this._sendOpt;

            // 保存横向纵向纬度
            self.saveAxisHandle();

        }

        self.$( "input:checkbox", self.Elems["dataValue"] ).click( function()
        {
            if( this.checked )
            {
                var oselect = this.parentNode.parentNode.parentNode.getElementsByTagName("select");

                var data = [
                    {
                        name : this.name || "null",
                        rank : "desc",
                        title : this.getAttribute("data-title") || "null",
                        values : self.$( oselect[ 0 ] ).select2("val").join(","),
                        value : ( function( data )
                        {
                            var res = [];

                            for( var i = 0, f; f = data[ i ]; i += 1  )
                            {
                                res.push( f.text );
                            };

                            return res.join("，") || "无";

                        })( self.$( oselect[ 0 ] ).select2("data") ),

                        uom : oselect[ 1 ].value || "null"
                    }];

                var element = self.Control.printDataToMapPanel( data, self.Tmps["vAxis"] );

                if( !self.Elems["valueAxis"].children.length ) self.Elems["valueAxis"].innerHTML = "";

                self.$( self.Elems["valueAxis"]).append( element );

                self.Control.saveRank( data[ 0 ].name, data[ 0 ].values.split(",")[ 0 ], data[ 0 ].rank )

                self.Control.saveValueAxis( data[ 0 ].name, data[ 0 ].values, data[ 0 ].uom );

                self.Control.saveTmpValueAxis( data[ 0 ].name, [ data[ 0 ].title , data[ 0 ].values || "NULL", data[ 0 ].value || "NULL" ] );
            }
            else
            {
                var elem = document.getElementById( this.name );

                if( elem )
                {
                    var current = elem.parentNode;

                    if( current.parentNode.children.length == 1 )
                    {
                        current.parentNode.innerHTML = "无";
                    }
                    else
                    {
                        self.$( elem.parentNode ).remove();
                    }
                }

                self.Control.deleteValueAxis( this.name );

                self.Control.deleteTmpValueAxis( this.name );

                self.Elems["closeEditMode"].onclick();
            }

            self.getViewItem( self.Control.getCondItem() );

            var optionsoFrag = ( function( item )
            {
                var ofrag = document.createDocumentFragment();

                for( var attr in item )
                {
                    var title = item[ attr ][ 0 ];
                    var tag = item[ attr ][ 1 ];
                    var value = item[ attr ][ 2 ];

                    var arr = tag.split(",");
                    var arr2 = value.split("，");

                    for( var i = 0, f; f = arr[ i ]; i += 1 )
                    {
                        var options = document.createElement("option");

                        options.value = attr + "_" + f;

                        options.innerHTML = title + " [" + arr2[ i ] + "]";

                        ofrag.appendChild( options );
                    }

                }

                return ofrag;

            })( self.Control.getTmpCondItem()["vAxis"] );

            self.Elems["getRankname"].innerHTML = "";

            if( optionsoFrag.children.length )
            {
                self.Elems["getRankname"].appendChild( optionsoFrag );
            }
            else
            {
                self.Elems["getRankname"].innerHTML = "<option value='null'>无</option>";
            };

            if( self.Elems["getRankname"].children.length ) self.Elems["getRankname"].children[ self.Elems["getRankname"].children.length - 1 ].selected = true;

            self.Elems["getRanktype"].children[ 0 ].selected = true;

            self.Elems["closeEditMode"].onclick();
        });

        self.Elems["topNum"].onchange = function()
        {
            var value = this.value ;
            self.Control.saveTopNum( value );

            self.getViewItem( self.Control.getCondItem() );
        };

        self.Elems["getRankname"].onchange = function()
        {
            var value = this.value + "_" + self.Elems["getRanktype"].value;

            var arr = value.split("_");

            self.Control.saveRank( arr[ 0 ], arr[ 1 ], arr[ 2 ] );

            self.getViewItem( self.Control.getCondItem() );
        }

        self.Elems["getRanktype"].onchange = function()
        {
            var value = self.Elems["getRankname"].value + "_" + this.value;

            var arr = value.split("_");

            self.Control.saveRank( arr[ 0 ], arr[ 1 ], arr[ 2 ] );

            self.getViewItem( self.Control.getCondItem() );
        }

        self.$( "select.ad-js-select", self.Elems["dataValue"] ).on("change", function()
        {
            var $input = self.$( "input:checkbox", this.parentNode );

            $input[ 0 ].checked = false;

            var elem = document.getElementById( $input[ 0 ].name );

            if( elem )
            {
                var current = elem.parentNode;

                if( current.parentNode.children.length == 1 )
                {
                    current.parentNode.innerHTML = "无";
                }
                else
                {
                    self.$( elem.parentNode ).remove();
                }
            }

            clearTimeout( this._timer );

            this._timer = setTimeout( function()
            {
                $input.click();

            }, 20 );

        });

        self.$( "select.ad-doc-selectlast", self.Elems["dataValue"] ).on("change", function()
        {
            var $input = self.$( "input:checkbox", this.parentNode );

            $input[ 0 ].checked = false;

            var elem = document.getElementById( $input[ 0 ].name );

            if( elem )
            {
                var current = elem.parentNode;

                if( current.parentNode.children.length == 1 )
                {
                    current.parentNode.innerHTML = "无";
                }
                else
                {
                    self.$( elem.parentNode ).remove();
                }
            }

            clearTimeout( this._timer );

            this._timer = setTimeout( function()
            {
                $input.click();

            }, 20 );

        });
    },

    _condModleEvent : function()
    {
        var self = this;

        var _moveTarget = null;

        var index = 0;

        var flag = null;

        self.$( self.Elems["tableAxisContainer"] ).on("click", "a", function()
        {

            if( !this._sendOpt ) return;

            self.$( this).find("i").click();

            var inputs = self.Elems["tabContent2"].getElementsByTagName("form")[ 0 ].getElementsByTagName("input");

            var aStep = this._sendOpt._step;

            self.Elems["addStep"].style.display = "none";

            self.$( "span.ad-js-setuom", self.Elems["tabContent2"] ).html( aStep[ 4 ] || "未知" );

            self.Elems["submitStep"]._range = parseInt( aStep[ 3 ] ) || 0;

            self.Elems["submitStep"]._uom = aStep[ 4 ] || "未知";

            self.Elems["submitStep"]._uomNum = aStep[ 5 ] || null;

            self.Elems["submitStep"]._sendOpt._step = aStep ;

            self.Elems["submitStep"]._sendOpt.dataStep = aStep;

            self.Elems["submitStep"]._sendOpt = this._sendOpt;

            self.$( self.Elems["setStep"] ).modal('show');

            self.$("#userStep .btn-danger.btn-sm").click();

            var _idx = this._sendOpt._idx;

            if( _idx == 0 )
            {
                var inputs = self.Elems["tabContent2"].getElementsByTagName("form")[ 0 ].getElementsByTagName("input");

                var res = this._sendOpt["value"];

                $(self.Elems["stepTab"].children[0]).find("a").click();

                inputs[0].value = res["start"] ;

                inputs[1].value = res["end"] ;

                inputs[2].value = res["step"] ;

            }
            else if( _idx == 1 )
            {
                self.Elems["addStep"].style["display"] = "inline-block";

                var res = this._sendOpt["value"]["arr"];

                var index = 1;

                while( index <res.length ){

                    self.Elems["addStep"].click();

                    index++;
                }

                var inputGroup = self.Elems["tabContent2"].getElementsByTagName("form")[ 1 ].children;

                $(self.Elems["stepTab"].children[1]).find("a").click();

                for( var i = 0 ; i < inputGroup.length ; i++ ){

                    var $oInputs = $( inputGroup[i]).find("input");

                    var aa = res[i].split(",");

                    $oInputs.eq(0).val( aa[0] );

                    $oInputs.eq(1).val( aa[1] );
                }

            }

        }).on("click","i.fa-times",function( ev ){

            if( this.parentNode.parentNode.parentNode.getAttribute( "data-name" ) == "V" )
            {
                self.$( "input[name='" + this.parentNode.id + "']", self.Elems["dataValue"])[ 0 ].checked = false;

                self.Control.deleteValueAxis( this.parentNode.id );
            }
            else
            {
                self.$( "a[data-name='" + this.parentNode.id + "']", self.Elems["dataAxis"]).removeClass("disabled");

                self.Control.deleteAxis( this.parentNode.id );
            }

            //self.Elems["closeEditMode"].onclick();

            self.getViewItem( self.Control.getCondItem() );

            if( !this.parentNode.parentNode.parentNode ) return false;

            if( this.parentNode.parentNode.parentNode.children.length == 1 )
            {
                this.parentNode.parentNode.parentNode.innerHTML = "无";

                return false;
            }

            this.parentNode.parentNode.parentNode.removeChild( this.parentNode.parentNode );

            ev.stopPropagation();

        }).on( "mousedown" , "a" , function( ev ){

            _moveTarget = {"target": this , "pX":ev.pageX , "pY": ev.pageY };

            this.style["border-style"] = "dashed";

            this.style["background-color"] = "#ebebeb";

            this.style["border-color"] = "#adadad";

        });

        self.$( window ).on("mousemove" , function( ev ){

            var pX = ev.pageX , pY = ev.pageY ;

            if( _moveTarget ){

                var iLeft = pX - _moveTarget["pX"] ;

                var dis = 50 ,oA ,oB ;

                var target = _moveTarget["target"];

                if( iLeft >= dis  ){

                    oA = $( target).parent();

                    oB = $( target ).parent().next();

                    flag = self.Control.exchange( oA ,oB );

                    flag&&index++;

                    _moveTarget["pX"] = pX;

                }else if( iLeft <= -dis){

                    oA = $( target ).parent();

                    oB = $( target ).parent().prev();

                    flag = self.Control.exchange( oA ,oB );

                    flag&&index--;

                    _moveTarget["pX"] = pX;
                }
            }

        }).on("mouseup" , function(){

            if( _moveTarget ){

                var target = _moveTarget["target"];

                target.style["border-style"] = "solid";

                target.style["background-color"] = "#fff";

                target.style["border-color"] = "#ccc";

                _moveTarget = null;

                if( index !=0 ){

                    self.saveAxisHandle();

                    self.Elems["tableAxisContainer"].style.zIndex = 0;
                }
            }

        });
    },

    _searchEvent : function()
    {
        var self = this;

        self.Elems["search"].onclick = function()
        {
            self.Elems["sreachwrap"].style.top = 0;
        }

        self.Elems["resetallsearchwrap"].onclick = function()
        {
            self.$( self.Elems["allsearchform"].getElementsByTagName("select") ).select2("val", "" );

            self.$( self.Elems["allsearchform"].getElementsByTagName("input") ).val("");

            self.Elems["submitallsearchwrap"].onclick();
        }

        self.Elems["closeallsearchwrap"].onclick = function()
        {
            self.Elems["sreachwrap"].style.top = -( self.Elems["sreachwrap"].offsetHeight + 20 ) + 'px';
        }

        self.$( self.Elems["saveConditioncontainer"] ).delegate( "li", "click", function( e )
        {
            if( e.target.tagName == "A" )
            {
                var value = e.target.getAttribute("data-cond");

                if( value )
                {
                    var JSONCONDS = JSON.parse( value );

                    var formGroup = self.Elems["allsearchform"].children;

                    for( var i = 0, f; f = formGroup[ i ]; i += 1 )
                    {
                        var selects = f.getElementsByTagName("select")[ 0 ];

                        var sName = f.getAttribute("data-name");

                        var whereData = JSONCONDS[ sName ];

                        if( selects )
                        {
                            $( selects ).select2( "val", whereData );
                        }
                        else
                        {
                            var inputs = f.getElementsByTagName("input");

                            inputs[ 0 ].value = whereData[ 0 ];

                            inputs[ 1 ].value = whereData[ 1 ];
                        }
                    }

                    self.Elems["submitallsearchwrap"].onclick();
                }

            }
            else if( e.target.tagName == "I" || e.target.tagName == "SAMP" )
            {
                // if( !confirm( "是否删除条件组？" ) ) return false;

                //localStorage.rankLocalData = ''; //删除localStorage中保存的条件组数据

                self.Control.deleteConditionGroup( self.$( e.target ).parents("a").attr("data-index") || null );

                self.$( this ).remove();

                if( !self.Elems["saveConditioncontainer"].children.length )
                {
                    self.$( self.Elems["saveallsearchdropdown"]).addClass("disabled");
                }
            }
        });

        /*if( localStorage.rankLocalData ){

         var element = self.Control.printDataToMapPanel( JSON.parse( localStorage.rankLocalData ), self.Tmps["saveCondition"] );

         self.$( self.Elems["saveConditioncontainer"] ).append( element );

         self.$( self.Elems["saveallsearchdropdown"]).removeClass("disabled");
         }*/

        self.Elems["saveallsearch"].onclick = function()
        {
            var value = prompt("保存当前条件，请先定义名称","");

            if( value )
            {
                if( value.length <= 10 )
                {
                    var formGroup = self.Elems["allsearchform"].children;

                    var data = {};

                    for( var i = 0, f; f = formGroup[ i ]; i += 1 )
                    {
                        var selects = f.getElementsByTagName("select")[ 0 ];

                        var sName = f.getAttribute("data-name");

                        var oCheckBox = self.$( "li[data-name='" + sName + "'] input", self.Elems["saveDwhereForm"] )[ 0 ];

                        if( selects )
                        {
                            data[ sName ] = self.$( f.getElementsByTagName("select") ).select2("val");

                            if( oCheckBox ) oCheckBox.checked = data[ sName ].length ? true : false;
                        }
                        else
                        {
                            var inputs = f.getElementsByTagName("input");

                            data[ sName ] = [];

                            data[ sName ].push( inputs[ 0 ].value );

                            data[ sName ].push( inputs[ 1 ].value );

                            if( oCheckBox ) oCheckBox.checked = data[ sName ][ 0 ] || data[ sName ][ 1 ] ? true : false;

                        }

                    }

                    var senddata = [{ index : self.Elems["saveConditioncontainer"].children.length, title : value || "未定义", data : JSON.stringify( data ) } ];

                    // 保存用户组
                    self.Control.saveConditionGroup( senddata );

                    //localStorage.rankLocalData = JSON.stringify( senddata ); //保存条件组数据到localStorage

                    var element = self.Control.printDataToMapPanel( senddata, self.Tmps["saveCondition"] );

                    self.$( self.Elems["saveConditioncontainer"] ).append( element );

                    self.$( self.Elems["saveallsearchdropdown"]).removeClass("disabled");

                    self.toastr.success("条件保存成功");

                    self.Elems["closeallsearchwrap"].onclick();
                }
                else
                {
                    self.toastr.warning("名称不能大于10字");
                }
            }
            else
            {
                self.toastr.warning("输入不能为空");
            }
        }

        self.Elems["submitallsearchwrap"].onclick = function()
        {
            var formGroup = self.Elems["allsearchform"].children;

            var data = {};

            var tmpData = [];

            for( var i = 0, f; f = formGroup[ i ]; i += 1 )
            {
                var selects = f.getElementsByTagName("select")[ 0 ];

                var sName = f.getAttribute("data-name");

                var oCheckBox = self.$( "li[data-name='" + sName + "'] input", self.Elems["saveDwhereForm"] )[ 0 ];

                var sTitle = f.getAttribute("data-title");

                var valueRes = [];

                if( selects )
                {
                    var selectData = self.$( f.getElementsByTagName("select") ).select2("data");

                    for( var p = 0, pf; pf = selectData[ p ]; p += 1 )
                    {
                        valueRes.push( pf.text );
                    }

                    if( valueRes.length )
                    {
                        tmpData.push({ value : "<span>" + valueRes.join("，") + "</span>", title : sTitle, id : "l_" + sName });
                    }

                    data[ sName ] = self.$( f.getElementsByTagName("select") ).select2("val");

                    if( oCheckBox ) oCheckBox.checked = data[ sName ].length ? true : false;
                }
                else
                {
                    var inputs = f.getElementsByTagName("input");

                    if( inputs[ 0 ].value || inputs[ 1 ].value )
                    {
                        tmpData.push(
                            {
                                value : "<span>" + ( inputs[ 0 ].value || "无限制" ) + self.$( inputs[ 0 ] ).next().text() + "</span>"
                                    + " 至 "
                                    + "<span>" + ( inputs[ 1 ].value || "无限制" ) + self.$( inputs[ 1 ] ).next().text() + "</span>",
                                title : sTitle, id : "l_" + sName
                            }
                        );
                    }

                    data[ sName ] = [];

                    data[ sName ].push( inputs[ 0 ].value );

                    data[ sName ].push( inputs[ 1 ].value );

                    if( oCheckBox ) oCheckBox.checked = data[ sName ][ 0 ] || data[ sName ][ 1 ] ? true : false;

                }

            }

            var element = self.Control.printDataToMapPanel( tmpData, self.Tmps["wAxis"] );

            self.$( self.Elems["condwrapper"] ).html( element.length ? element : "暂无" );

            self.Control.saveWhere( data );

            var sendData = self.Control.getCondItem();

            if( sendData["xAxis"] && sendData["yAxis"] && sendData["vAxis"] )
            {
                self.getTableItem( sendData );
            }
            else
            {
                if( !( sendData["xAxis"] ||  sendData["yAxis"] ) )
                {
                    self.$( "a:eq( 0 )", self.Elems["tabs2"] ).tab("show");

                    self.toastr.warning("你还未选择<维度>");
                }
                else if( !sendData["vAxis"] )
                {
                    self.$( "a:eq( 1 )", self.Elems["tabs2"] ).tab("show");

                    self.toastr.warning("你还未选择<统计方式>");
                }

                self.Elems["configMode"].onclick();
            }

            self.Elems["closeallsearchwrap"].onclick();
        }

        self.$( self.Elems["condwrapper"] ).delegate( "li", "click", function()
        {
            // if( !confirm( "是否撤销此条件项？") ) return false;

            var group = self.$( "div[data-name='" + this.children[ 0 ].id.substring( 2 ) + "']", self.Elems["allsearchform"] )[ 0 ];

            var oselect = group.getElementsByTagName("select");

            if( oselect[ 0 ] )
            {
                self.$( oselect ).select2("val", "");
            }
            else
            {
                var inputs = group.getElementsByTagName("input");

                inputs[ 0 ].value = inputs[ 1 ].value = "";
            }

            self.Elems["submitallsearchwrap"].onclick();

            if( this.parentNode && this.parentNode.children.length == 1 )
            {
                self.Elems["condwrapper"].innerHTML = "暂无";

                return false;
            }

            this.parentNode && this.parentNode.removeChild( this );
        })
    },

    _saveModel : function()
    {
        var self = this;

        self.Elems["submitModel"].onclick = function()
        {
            var data = self.Control.getSubmitConditionItem();

            if( !( !self.$.isEmptyObject( data["xAxis"] ) || !self.$.isEmptyObject( data["yAxis"] ) ) )
            {
                self.$( "a:eq( 0 )", self.Elems["tabs2"] ).tab("show");

                self.toastr.warning("你还未选择<维度>");

                self.Elems["configMode"].onclick();

                return false;
            }

            if( self.$.isEmptyObject( data["vAxis"] ) )
            {
                self.$( "a:eq( 1 )", self.Elems["tabs2"] ).tab("show");

                self.toastr.warning("你还未选择<统计方式>");

                self.Elems["configMode"].onclick();

                return false;
            }

            self.$( self.Elems["saveModel"] ).modal("show");
        }

        var oTableColorLevelRender = new self.TableColorLevelRender();

        self.Elems["colorLevels"].onclick = function()
        {
            var $elem = self.$( self.Elems["tablecontainer"].getElementsByTagName("td") );

            if( !$elem[ 0 ] )
            {
                self.toastr.warning("无数据，无法生成色阶");

                return false;
            }

            oTableColorLevelRender.setItem( $elem );

            if( !self.Elems["tablecontainer"].children[ 0 ].children[ 0 ].getAttribute("data-level") )
            {
                self.toastr.warning("当前模型不支持色阶功能");
                return false;
            }

            if( this._st )
            {
                oTableColorLevelRender.clearLevels();

                this._st = 0;

                this.innerHTML = '<i class="fa fa-fire"></i> 打开色阶';
            }
            else
            {
                oTableColorLevelRender.getSelfArray( oTableColorLevelRender.originElements );

                var result = oTableColorLevelRender.selfSort( oTableColorLevelRender.selfArray ) || [];

                oTableColorLevelRender.setRender( result );

                this._st = 1;

                this.innerHTML = '<i class="fa fa-fire"></i> 关闭色阶';
            }
        }

        self.$( "input:radio", self.Elems["saveModelForm"] ).click( function()
        {
            if( this.name == "icon" )
            {
                self.Elems["setIco"].className = "ico_" + this.value;
            }
            else if( this.name == "bg" )
            {
                self.Elems["setStyle"].className = "style_" + this.value;
            }
        });

        self.$( "input:text", self.Elems["saveModelForm"] ).keyup( function()
        {
            if( this.value.length > 10 )
            {
                this.value = this.value.substring( 0, 10 );
            }
            else
            {
                self.Elems["setTitle"].innerHTML = this.value || "请输入分析模型标题";
            }
        });

        self.Elems["saveModelBtn"].onclick = function()
        {
            var data = self.$( self.Elems["saveModelForm"] ).serializeArray();

            var UI_DATA = {};

            for( var attr in data )
            {
                var _t = data[ attr ];

                if( !_t.value || _t.value == "default" )
                {
                    if( _t.name == "icon" )
                    {
                        self.toastr.warning("请选择 [ 图标 ]");
                    }
                    else if( _t.name == "bg" )
                    {
                        self.toastr.warning("请选择 [ 背景色 ]");
                    }
                    else if( _t.name == "title" )
                    {
                        self.toastr.warning("请输入 [ 标题 ]");
                    }

                    return false;
                }

                if( _t.name.indexOf("[]") == -1 )
                {
                    UI_DATA[ _t.name ] = _t.value;
                }
                else
                {
                    var name = _t.name.substring( 0, _t.name.indexOf("[]") );

                    UI_DATA[ name ] = UI_DATA[ name ] || [];

                    UI_DATA[ name ].push( _t.value );
                }
            }

            var ddata = self.$( self.Elems["saveDwhereForm"] ).serializeArray();

            var DWHERE_DATA = [];

            for( var attr2 in ddata )
            {
                DWHERE_DATA.push(  ddata[ attr2 ].name )
            }

            self.Control.saveUI( UI_DATA );

            self.Control.saveDwhere( DWHERE_DATA );

            self.saveModel( self.Control.getCondItem() );
        }
    },

    _chartsControl : function()
    {
        var self = this;

        var oCanvasDown = new self.CanvasDown();

        var chartsList = self.Elems["chartsList"];

        chartsList && self.$( chartsList ).delegate( "a", "click", function()
        {
            self.beforeSend();

            var container = self.Elems["chartsContainer"];

            container.style.zIndex = 3;

            container._btn = this;

            var chart = new ChartsControl( self.charts );

            chart.init( this.getAttribute("data-tag"), self.Control.getItem(),{
                error : function( infoData )
                {
                    self.toastr.warning( infoData );
                }
            } );

            self.Elems["condparent"].style.display = "none";
            self.Elems["chartstitle"].style.display = "block";

            self.$( [ self.Elems["exitCharts"], self.Elems["saveCharts"] ] ).show();
            self.$( [ self.Elems["search"], self.Elems["saveallsearchdropdown"], self.Elems["configMode"], self.Elems["submitModel"] ] ).hide();

            self.afterSend();

            self.chartBtn = this;
        });

        self.Elems["exitCharts"].onclick = function()
        {
            var container = self.Elems["chartsContainer"];

            container.style.zIndex = -1;

            self.Elems["condparent"].style.display = "block";
            self.Elems["chartstitle"].style.display = "none";

            self.$( [ self.Elems["exitCharts"], self.Elems["saveCharts"] ] ).hide();
            self.$( [ self.Elems["search"], self.Elems["saveallsearchdropdown"], self.Elems["configMode"], self.Elems["submitModel"] ] ).show();
        }

        self.Elems["saveCharts"].onclick = function()
        {
            oCanvasDown.saveImageInfo( self.Elems["chartsContainer"], this );
        }
    },

    bindEvent : function()
    {
        this._sideBarEvent();

        this._condEvent();

        this._condModleEvent();

        this._searchEvent();

        this._saveModel();

        this._chartsControl();

        this._modalLayer();

        this._linkToXCase();
    },

    _modalLayer : function()
    {
        var self = this;

        self.$( self.Elems["searchModal1"] ).on('show.bs.modal', function (e)
        {
            self.Elems["searchModaltextarea"].value = "";

            var DATA = [];

            var oselect = e.relatedTarget.parentNode.getElementsByTagName("select");

            for( var i = 0, elem = oselect[ 0 ].children, f; f = elem[ i ]; i += 1 )
            {
                DATA.push({ title : f.innerHTML, value : f.value });
            }

            self.Elems["searchModalbtn"]._value = DATA;

            self.Elems["searchModalbtn"]._select = oselect;

        })

        self.Elems["searchModalbtn"].onclick = function()
        {
            if( this._value )
            {
                var newArray = [];

                var strs = self.Elems["searchModaltextarea"].value.split("，");

                for( var p = 0, pf; pf = strs[ p ]; p += 1 )
                {
                    for( var i = 0, f; f = this._value[ i ]; i += 1 )
                    {
                        if( f.title.indexOf( pf ) != -1 )
                        {
                            newArray.push(f.value );
                        }
                    }
                }

                self.$( this._select ).select2("val", newArray).change();

                self.$( self.Elems["searchModal1"] ).modal("hide");
            }
        }

        self.$( self.Elems["searchModal2"] ).on('show.bs.modal', function ( e )
        {
            var oselect = e.relatedTarget.parentNode.getElementsByTagName("select");

            self.Elems["searchModalSubmit"]._select = oselect;

            if( oselect[ 0 ] )
            {
                var DATA = [];

                var checked = self.$( oselect ).select2('val');

                for( var i = 0, elem = oselect[ 0 ].children, f; f = elem[ i ]; i += 1 )
                {
                    DATA.push({ title : f.innerHTML, value : f.value, checked : checked.indexOf( f.value ) == -1 ? "" : "checked"  });
                }

                var element = self.Control.printDataToMapPanel( DATA, self.Tmps["checkboxLayer"] );

                self.$( self.Elems["searchModal2content"] ).html( element );
            }
        })

        self.Elems["searchModalCheckAll"].onclick = function()
        {
            var checks = self.Elems["searchModal2content"].getElementsByTagName("input");

            for( var i = 0, f; f = checks[ i ]; i += 1 )
            {
                f.checked = true;
            }
        }

        self.Elems["searchModalReCheck"].onclick = function()
        {
            var checks = self.Elems["searchModal2content"].getElementsByTagName("input");

            for( var i = 0, f; f = checks[ i ]; i += 1 )
            {
                f.checked = f.checked ? false : true;
            }
        }

        self.Elems["searchModalSubmit"].onclick = function()
        {
            var checks = self.Elems["searchModal2content"].getElementsByTagName("input");

            var value = [];

            for( var i = 0, f; f = checks[ i ]; i += 1 )
            {
                if( f.checked )
                {
                    value.push( f.value );
                }
            }

            self.$( this._select ).select2("val", value).change();

            self.$( self.Elems["searchModal2"] ).modal("hide");
        }
    },


    /** 请求前处理*/
    beforeSend : function()
    {
        var oloading = this.Elems["loading"];

        oloading.style.display = "block";
        oloading.style.opacity = 1;
        oloading.style["-webkit-transition"] =
            oloading.style["-moz-transition"] =
                oloading.style["-o-transition"] =
                    oloading.style["transition"] = "opacity 0.35s ease";
    },

    afterSend : function()
    {
        var oloading = this.Elems["loading"];

        oloading.style.opacity = 0;
        oloading.style.display = "none";
    },

    getViewSuccess : function( jsonItem )
    {
        if( !jsonItem ) return false;

        var table = new this.DataGrid({
            target: this.Elems["tableViewContainer"],
            item : jsonItem
        });

        if( !( table.headItem  || table.bodyItem || table.footItem ).length  )
        {
            var element = this.Control.printDataToMapPanel( [[]], this.Tmps["nullData"] );

            this.$( this.Elems["tableViewContainer"] ).html( element );
        }

        this.afterSend();
    },

    getViewItem : function( data, callback )
    {
        var callbackObject = {
            context : this,
            success: this.getViewSuccess || function(){},
            beforeSend : this.beforeSend || function(){},
            callback : callback || function(){}
        };

        data["type"] = this.analysisType;

        data["code"] = this.analysisCode;

        this.Control.post( this.Paths.getViewDataPath , data, callbackObject, "json"  )
    },

    getTableSuccess : function( jsonItem )
    {
        this.Control.setItem( jsonItem || {} );

        if( !jsonItem ) return false;

        if( jsonItem.c )
        {
            if( jsonItem.c["t"].length )
            {
                this.Elems["dropdown"].style.display = "inline-block";

                var tmpData = [];

                for( var c = 0, cf; cf = jsonItem.c["t"][ c ]; c += 1 )
                {
                    var str = "";

                    switch( cf )
                    {
                        case "line" : str = "折线图";
                            break;
                        case "bar" : str = "柱形图";
                            break;
                        case "pie" : str = "饼状图";
                            break;
                        case "xBar" : str = "比例柱状图";
                            break;
                        case "yBar" : str = "比例条形图";
                            break;
                        case "fixed" : str = "量价图";
                            break;
                        default : str = "未知";
                    }

                    tmpData.push({ title : str, value : cf });
                }

                var element = this.Control.printDataToMapPanel( tmpData, this.Tmps["chartsTemplate"] );

                this.$( this.Elems["chartsList"] ).html( element );
            }
            else
            {
                this.Elems["dropdown"].style.display = "none";
            }
        }

        if( jsonItem.d )
        {

            this.Elems['closeEditMode'].onclick();

            this.Elems['closeSide'].onclick();

            var self = this;

            var oSortTool = new SortTool();

            var JSONDATA = jsonItem;

            var table = new this.DataGrid({
                target: this.Elems["tablecontainer"],
                item : JSONDATA["d"],
                headThClick : function()
                {
                    var filed = this.className.substring( 2 );

                    oSortTool.setItem( JSONDATA );

                    var result = oSortTool.sortDescItem( filed ) || null;

                    if( result )
                    {
                        this.currentObj.reInitialize({
                            item : result["d"]
                        });

                        var tag = this.className.split(" ")[ 0 ].substring( 2 );

                        self.$( document.getElementsByClassName( "grid_groud" ) ).removeClass("grid_groud");

                        self.$( document.getElementsByClassName( "b_" + tag ) ).addClass("grid_groud");

                        self.$( "th.h_" + tag, this.currentObj._target ).addClass("grid_groud").siblings().removeClass("grid_groud");

                        self.Elems["colorLevels"]._st = 0;

                        self.Elems["colorLevels"].innerHTML = '<i class="fa fa-fire"></i> 打开色阶';
                    }
                }
            });


            if( table.bodyItem )
            {
                if( !table.bodyItem.length )
                {
                    var element = this.Control.printDataToMapPanel( [[]], this.Tmps["nullData"] );

                    this.$( this.Elems["tablecontainer"] ).html( element );
                }
            }
            else
            {
                var element = this.Control.printDataToMapPanel( [], this.Tmps["nullData"] );

                this.$( this.Elems["tablecontainer"] ).html( element );
            }
        }

        this.afterSend();

        this.Elems["colorLevels"]._st = 0;

        this.Elems["colorLevels"].innerHTML = '<i class="fa fa-fire"></i> 打开色阶';
    },

    getTableItem : function( data, callback )
    {
        var callbackObject = {
            context : this,
            success: this.getTableSuccess || function(){},
            beforeSend : this.beforeSend || function(){},
            callback : callback || function(){}
        };

        data["type"] = this.analysisType;

        data["code"] = this.analysisCode;

        this.Control.post( this.Paths["getTableDatapath"], data, callbackObject, "json"  )
    },

    saveModelSuccess : function( res )
    {
        if( res ) this.$( "a:eq(0)" , top.document.getElementById("js-nav") ).click().mouseover();
    },

    saveModel : function( data, callback )
    {
        var callbackObject = {
            context : this,
            success: this.saveModelSuccess || function(){},
            beforeSend : this.beforeSend || function(){},
            callback : callback || function(){}
        };

        data["type"] = this.analysisType;

        data["code"] = this.analysisCode;

        this.Control.post( this.Paths["getSavaModelPath"], data, callbackObject, "json"  )
    },
    _linkToXCase: function () {
        this.H.jumpProject();
    }

};